home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-13 | 3.5 KB | 109 lines | [TEXT/KAHL] |
- // This may look like C code, but it is really -*- C++ -*-
- //************************************************************************
- //
- // A standard Macintosh environment
- // I am accustomed to
- //
- // $Id: myenv.h,v 1.3 1995/02/08 17:23:51 oleg Exp oleg $
-
- #pragma once
- #ifndef _mymenv_h
- #define _mymenv_h 1
-
-
- /* Alert the user and that we're about */
- /* to die */
- volatile void _die(
- const char * message, /* Message to be printed */
- ... /* Additional args to printf */
- );
-
- /* Alert the user */
- void alert(
- const char * text, /* Message to be printed */
- ... /* Additional args to printf */
- );
-
-
-
- //------------------------------------------------------------------------
- // Macintosh convenience functions
-
-
- // Pascal String, this is just a type conversion
- class Pstr
- {
- Str255 pas_string;
- public:
- Pstr(const char * c_str);
- operator unsigned char const * (void) { return pas_string; }
- };
-
- //------------------------------------------------------------------------
- // Patches to the standard environment
-
- #ifndef _myenv_h
- // Like strncpy(), but ALWAYS terminates
- // the destination string
- char * xstrncpy(char * dest, const char * src, const int len);
- #endif
-
- //------------------------------------------------------------------------
- // Verify the assertion
-
- #ifndef assert
- #define assert(ex) \
- (void)((ex) ? 1 : \
- (_die("Failed assertion " #ex " at line %ld of `%s'.", \
- __LINE__, __FILE__), 0))
- #endif
- #ifndef assertval
- #define assertval(ex) assert(ex)
- #endif
-
- #ifndef assure
- #define assure(expr,message) \
- if (expr) ; \
- else _die("%s at line %ld of '%s'.",message,__LINE__, __FILE__);
- #endif
- // Execute the function 'ex' and make sure
- // it return noErr
- #define do_well(ex) \
- { OSErr err = (ex); if( err != noErr ) \
- _die("Failed call " #ex " with error %ld at line %ld of `%s'.", \
- err, __LINE__, __FILE__); }
-
- //------------------------------------------------------------------------
- // Notification posting
- // The set of functions below let a (backgound) application to post
- // synchronous or asynchronous notification messages to the user.
- // Synchronous posting means that function does not return until the
- // notification message is displayed and the user dismisses it.
- // In asynchronous mode, the posting function returns as soon as the
- // message is queued into the notification queue (but not yet displayed!).
- //
-
- void notify_and_wait(const char * messg,...);
- void notify(const char * messg,...);
-
- //------------------------------------------------------------------------
- // Sound playing on errors
-
- void set_error_sound(Str255 sound_name);
-
- //------------------------------------------------------------------------
- // Macintosh System Utilities
-
-
-
- void Initialize_MAC(void);
- void sleep(const int nticks); // Generous suspension for a specified no. of ticks
-
- // Launch an application and have it handle the
- // specified file, as if the file were
- // "double-clicked"
- void open_selection(const char * full_path_name);
-
-
- #endif
-